<script setup name="DocList">
const props = defineProps({
    tabledata: {
        type: Array,
        default: () => []
    },
    currentpage: {
        type: Number,
        default: 1
    },
    total: {
        type: Object,
        default: null
    },
    listdata: {
        type: Object,
        default: () => {}
    },
    reset: {
        type: Boolean,
        default: false
    },
    major: {
        type: Object,
        default: null
    },
    grade: {
        type: Object,
        default: null
    },
    classnum: {
        type: Object,
        default: null
    }
})

const emit = defineEmits(['on-success'])

function beforeUpload(file) {
    const fileName = file.name.split('.')
    const fileExt = fileName[fileName.length - 1]
    const isTypeOk = props.ext.indexOf(fileExt) >= 0
    const isSizeOk = file.size / 1024 / 1024 < props.size
    if (!isTypeOk) {
        ElMessage.error(`上传文档只支持 ${ props.ext.join(' / ') } 格式！`)
    }
    if (!isSizeOk) {
        ElMessage.error(`上传文档大小不能超过 ${props.size}MB！`)
    }
    return isTypeOk && isSizeOk
}
function onExceed() {
    ElMessage.warning('文档上传超过限制')
}
function onSuccess(res, file, fileList) {
    emit('on-success', res, file, fileList)
}
</script>

<template>
    <div style="margin-left: 1px;margin-right: 1%;">
        <el-row>
            <el-col v-for="(o, index) in 18" :key="o" :span="4" :offset="index > 0 ? 2 : 0">
                <div style="margin-top: 15px;">
                    <div style="width: 50px; height: 20px;" />
                    <el-card :body-style="{ padding: '0px'}" shadow="hover">
                        <img src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png" class="image">
                        <div style="padding: 14px;">
                            <span>Yummy hamburger</span>
                            <div class="bottom">
                                <time class="time">{{ currentDate }}</time>
                                <el-button text class="button">Operating</el-button>
                            </div>
                        </div>
                    </el-card>
                </div>
            </el-col>
        </el-row>
        <div style="margin-left: 35%;">
            <div class="block">
                <el-pagination
                    :current-page="currentpage"
                    :page-sizes="[4,8, 12, 16]"
                    :page-size="pagesize"
                    layout="total, sizes, prev, pager, next"
                    :total="total"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                />
            </div>
        </div>
    </div>
</template>

<style lang="scss" scoped>
:deep(.el-upload.is-drag) {
    display: inline-block;
    .el-upload-dragger {
        padding: 0;
    }
    &.is-dragover {
        border-width: 1px;
    }
    .slot {
        width: 300px;
        padding: 40px 0;
    }
}
.image {
    width: 100%;
    display: block;
}
</style>
